$import( "SmitearWebGL.Objects.Parser.Collada.DaeEntity" );

SmitearWebGL.Objects.Parser.Collada.DaeAccessor = SmitearWebGL.Objects.Parser.Collada.DaeEntity.extend(
{
	/******** constructor ********/

	init : function( document, node )
	{
		this.count = 0;
		this.source = "";
		this.offset = 0;
		this.stride = 0;
		this.params = null;

		this._super( document, node );
		this._registClass( "SmitearWebGL.Objects.Parser.Collada.DaeAccessor" );
	}
	,
	
	/******** public method ********/
	
	read : function( node )
	{
		$THROW( node.localName == SmitearWebGL.Objects.Parser.Collada.Const.DAE_ACCESSOR_ELEMENT,
		"expected a " + SmitearWebGL.Objects.Parser.Collada.Const.DAE_ACCESSOR_ELEMENT + " element" );

		this._super( node );

		this.count = this.getAttributeAsInt(node, SmitearWebGL.Objects.Parser.Collada.Const.DAE_COUNT_ATTRIBUTE);
		this.offset = this.getAttributeAsInt(node, SmitearWebGL.Objects.Parser.Collada.Const.DAE_OFFSET_ATTRIBUTE);
		this.source = this.getAttribute(node, SmitearWebGL.Objects.Parser.Collada.Const.DAE_SOURCE_ATTRIBUTE);
		this.stride = this.getAttributeAsInt(node, SmitearWebGL.Objects.Parser.Collada.Const.DAE_STRIDE_ATTRIBUTE, 1);

		var paramList = this.getNodeList(node, SmitearWebGL.Objects.Parser.Collada.Const.DAE_PARAMETER);

		this.params = {};

		// params
		for( var i = 0; i < paramList.length; i++ )
		{
			var param = paramList[i];
			var name = this.getAttribute(param, SmitearWebGL.Objects.Parser.Collada.Const.DAE_NAME_ATTRIBUTE);
			var type = this.getAttribute(param, SmitearWebGL.Objects.Parser.Collada.Const.DAE_TYPE_ATTRIBUTE);
			this.params[ name ] = type;
		}
	}
}
);